/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.SQLException;
import java.util.Date;
import pojo.*;

/**
 *
 * @author Thanh Minh dep trai
 */
public class BaoCaoDoanhThuDAO {
     public static int themBaoCaoDoanhThu(BaoCaoDanhThu B) {
        int n = -1;
        try {
            MysqldataAccesshelper helper = new MysqldataAccesshelper();
            helper.open();
            String sql = String.format("INSERT INTO baocaodoanhthu (Ngay,SoBenhNhan,DoanhThu) VALUES (%s,%d,%f)", B.getNgay(),B.getSoBenhNhan(),B.getDoanhThu());
            n = helper.executeUpdate(sql);
            helper.close();
        } catch (SQLException ex) {
            System.out.println("Them that bai" + ex);
        }

        return n;
    }
    public static int suaBaoCaoDanhThu(Date Ngay , int sobenhnhan , double doanhthu) {
        int n = -1;
        try {
            MysqldataAccesshelper helper = new MysqldataAccesshelper();
            helper.open();
            String sql = String.format("UPDATE  baocaodoanhthu SET SoBenhNhan=%d ,DoanhThu=%d  where Ngay='%s' ",sobenhnhan,doanhthu,Ngay);
            n = helper.executeUpdate(sql);
            helper.close();
        } catch (SQLException ex) {
            System.out.println("Cap nhat that bai" + ex);
        }

        return n;
    }
    public static int xoaQuyDinh(int Ngay) {
        int n = -1;
        try {
            MysqldataAccesshelper helper = new MysqldataAccesshelper();
            helper.open();
            String sql = String.format("DELETE FROM baocaodoanhthu WHERE Ngay='%s' ",Ngay);
            n = helper.executeUpdate(sql);
            helper.close();
        } catch (SQLException ex) {
            System.out.println("Xoa that bai" + ex);
        }

        return n;
    }
}
